/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.kyle.bbdroid;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 *
 * @author kyle
 */
public class bbDroid extends Activity {

    private httpHandler http = new httpHandler();
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        
        Button btn_settings = (Button) findViewById(R.id.btn_settings);
        btn_settings.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                
                Intent intent_settings = new Intent(getApplicationContext(), bbDroidSettings.class);
                startActivityForResult(intent_settings, 2802);
                
            }
        });
        
        
        Button btn_check = (Button) findViewById(R.id.btn_check);
        btn_check.setOnClickListener(new OnClickListener() {

            EditText entry_url = (EditText) findViewById(R.id.entry_url);
            
            public void onClick(View v) {
                CharSequence url = entry_url.getText();
                
                Toast.makeText(getApplicationContext(), http.getTagContent(http.getHtml(String.valueOf(url)), "title"), Toast.LENGTH_LONG).show();
            }
        });
        
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent settings){
        super.onActivityResult(requestCode, resultCode, settings);
        
        if(requestCode == 2802){
            Toast tost = Toast.makeText(getApplicationContext(), settings.getStringExtra("url"), 1000);
            tost.show();
        }
        
    }
    
}
